package authentication.token.server;

import authentication.token.Request;
import authentication.token.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author yuqi<307530884@qq.com> <2017/3/28>
 * @version 1.0
 * @since 1.0
 */
public class AuthFilter implements Filter {

    protected transient final Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public boolean doFilter(Request request, Response response) {

        boolean valid = true;

        String url = request.get(Request.url);

        if(url == null || "".equals(url)){
            response.put(Response.HTTP_CODE, "401");
            valid = false;
        }else if(url.equals(LoginController.GET_LIST_URL)){
            //校验token安全性
            response.put(Response.HTTP_CODE, "403");

            valid = false;
        }

        return valid;
    }
}
